GBML manual / Strings

string_delete

text with count characters taken out, starting at position at (0-based) - string_delete("chat", 1, 1) is "cat". The result is never longer than text, so it never runs out of room.

Syntax

string_delete(text, at, count) -> string

Arguments

NameType
textstring
atint
countint

Returns

string

Description

text with count characters taken out, starting at position at: string_delete("chat", 1, 1) is "cat". The answer is never longer than text, so it never runs out of room.

Positions count from 0, exactly like string_char_at. It never crashes: an at below 0 acts as 0, an at past the end deletes nothing, a count of 0 or less deletes nothing, and a count that runs past the end deletes up to the end and no further.

string_slice is the other way round: it keeps a part, where string_delete throws a part away.

Example

var word = "chat";
var cat = string_delete(word, 1, 1);          // "cat"
var hat = string_delete(word, 0, 1);          // "hat"
var cha = string_delete(word, 3, 99);         // "cha" - 99 runs past the end, so it stops at the end
var same = string_delete(word, 99, 2);        // "chat" - nothing there to delete

On the GBA

Counts from 0, like string_char_at. Never a crash: an at below 0 acts as 0, an at past the end deletes nothing, a count of 0 or less deletes nothing, and a count that runs past the end deletes up to the end and no further. Takes text out; use string_slice to keep a part instead.

See also: string_insertstring_slicestring_replace